package com.societyGames.codeAlong.state.codeExercise.model
{
import com.societyGames.codeAlong.localization.StringManager;
import com.societyGames.codeAlong.state.codeExercise.model.link.IHyperText;
import com.societyGames.codeAlong.state.codeExercise.model.link.ILinkable;

public class FunctionReturnData implements ILinkable, IHyperText
	{
		private static const _returnId:String = "return";
		private var _parent:ILinkable;

		public var type:String = "void";
		public var description:String = StringManager.getString("returnDescriptionDefault");
		
		public function FunctionReturnData()
		{
		}
		
		//IHyperText-->		
		public function toHyperText():String
		{
			return type;
		}
		//<--IHyperText
		
		//ILinkable-->
		public function toLink():String
		{
			return this._parent.toLink() + _returnId;
		}
		//<--ILinkable
		
		/**
		 * Generate ReturnData from XML.
		 **/
		public static function fromXml(parent:ILinkable, xml:XML):FunctionReturnData
		{
			var returnData:FunctionReturnData = new FunctionReturnData();
			returnData._parent = parent;
			if (xml != null)
			{
				returnData.type = xml.@type;
				returnData.description = xml.@description;
			}
			return returnData;
		}
	}
}